import request from '@/utils/request'

/**
 * 用户登录
 * @param {*} data
 * @returns
 */
export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data: {
      username: data.username,
      password: data.password
    }
  })
}

/**
 * 获取用户信息
 * @param {*} token
 * @returns
 */
export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

/**
 * 登出
 * @returns
 */
export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

/**
 * 用户注册
 * @param {*} data
 * @returns
 */
export function register(data) {
  return request({
    url: '/user/register',
    method: 'post',
    data
  })
}

/**
 * 获取分页数据
 * @param {*} params
 * @returns
 */
export function getList(params) {
  return request({
    url: '/user/page',
    method: 'get',
    params
  })
}

/**
 * 更新数据
 * @param {*} data
 * @returns
 */
export function updateRow(data) {
  return request({
    url: '/user/update/admin',
    method: 'put',
    data
  })
}

/**
 * 删除数据
 * @param {*} ids
 * @returns
 */
export function deleteRow(ids) {
  return request({
    url: '/user/delete',
    method: 'delete',
    params: { ids: ids.join(',') }
  })
}
